import SvgIcon from '@/components/SvgIcon/index.vue'
import Pagination from '@/components/Paginaton/index.vue'
import Category from '@/components/Category/index.vue'
import type { App, Component } from 'vue'
//引入element 图标组件
import * as ElementIconsVue from '@element-plus/icons-vue'
//全局对象  key:value省略value
const allGlobalComponent: Component = { SvgIcon, Pagination, Category }

//对外暴露插件对象
export default {
    install(app: App) {
        Object.keys(allGlobalComponent).forEach(key => {
            //注册为全局组件
            app.component(key, allGlobalComponent[key])
        })
        //将element-plus提供图标注册为全局组件
        /* const person = {
            name: 'Alice',
            age: 25,
            city: 'New York'
          };
          
          const entries = Object.entries(person);
          console.log(entries);
          输出:   [ ['name', 'Alice'], ['age', 25], ['city', 'New York'] ] */

        for (const [key, component] of Object.entries(ElementIconsVue)) {
            app.component(key, component)
        }
    }
}